﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Web.UI.WebControls;

/// <summary>
/// Summary description for AssetConfig
/// </summary>
public class AssetConfig
{
	public AssetConfig()
	{
	}

    public DataSet getAssetDataSet(String cat)
    {
        if(cat.Equals("Computers"))
        {
            ComputerDBConnection computerConn = new ComputerDBConnection();
            return computerConn.getComputerDataSet();
        }
        else if (cat.Equals("Software"))
        {
            SoftwareDBConnection softwareConn = new SoftwareDBConnection();
            return softwareConn.getSoftwareDataSet();
        }
        else if (cat.Equals("Other"))
        {
            OtherDBConnection otherConn = new OtherDBConnection();
            return otherConn.getOtherDataSet();
        }
        return new DataSet();
    }

    public DataSet getAssetDataSet(String cat, int assetID)
    {
        if (cat.Equals("Computers"))
        {
            ComputerDBConnection computerConn = new ComputerDBConnection();
            return computerConn.getComputerDataSet(assetID);
        }
        else if (cat.Equals("Software"))
        {
            SoftwareDBConnection softwareConn = new SoftwareDBConnection();
            return softwareConn.getSoftwareDataSet(assetID);
        }
        else if (cat.Equals("Other"))
        {
            OtherDBConnection otherConn = new OtherDBConnection();
            return otherConn.getOtherDataSet(assetID);
        }
        return new DataSet();
    }

    public ListItem[] getCategoryAdvSearchDdl(String cat)
    {
        ListItem[] list = new ListItem[3];
        if (cat.Equals("Computers"))
        {
            list = new ListItem[2];
            list[0] = new ListItem("Computer_Name");
            list[1] = new ListItem("*Parts not used");
            //list[2] = new ListItem("Purchase_Date");
            return list;
        }
        else if (cat.Equals("Software"))
        {
            list = new ListItem[2];
            list[0] = new ListItem("Software_Name");
            list[1] = new ListItem("Brand_Name");
            return list;
        }
        else if (cat.Equals("Other"))
        {
            list = new ListItem[3];
            list[0] = new ListItem("Type");
            list[1] = new ListItem("Asset_Name");
            list[2] = new ListItem("Brand_Name");
            return list;
        }
        return list;
    }

    public DataSet getAssetDataSet_ByAdvSearch(String cat, String searchBy, String assetID)
    {
        if (cat.Equals("Computers") && searchBy.Equals("*Parts not used"))
        {
            PartDBConnection partConn = new PartDBConnection();
            return partConn.getPartDataSet();

        }
        else if (cat.Equals("Computers"))
        {
            ComputerDBConnection computerConn = new ComputerDBConnection();
            return computerConn.getComputerDataSet_ByAdvStrSearch(searchBy, (String)assetID);
        }
        else if (cat.Equals("Software"))
        {
            //SoftwareDBConnection softwareConn = new SoftwareDBConnection();
            //return softwareConn.getSoftwareDataSet(assetID);
        }
        else if (cat.Equals("Other"))
        {
            OtherDBConnection otherConn = new OtherDBConnection();
            return otherConn.getOtherDataSet_ByAdvStrSearch(searchBy, (String)assetID);
            //OtherDBConnection otherConn = new OtherDBConnection();
            //return otherConn.getOtherDataSet(assetID);
        }
        return new DataSet();
    }

    public void addPart(Part part)
    {
        PartDBConnection partConn = new PartDBConnection();
        part.part_ID = partConn.getNewPartNo();

        partConn.insert(part);
    }












}